package com.ruoyi.supervise.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.supervise.domain.ProsAccess;
import com.ruoyi.supervise.mapper.ProsAccessMapper;
import com.ruoyi.supervise.service.IProsAccessService;

import cn.hutool.core.util.StrUtil;

/**
 * @ClassName: MyTestServiceImpl
 * @Description: 测试从数据源
 * @Author wtj
 * @DateTime 2020年3月9日 上午10:41:31
 */
@Service
@DataSource(value = DataSourceType.SLAVE)
public class ProsAccessServiceImpl implements IProsAccessService 
{
    @Autowired
    private ProsAccessMapper prosAccessMapper;

	@Override
	public ProsAccess selectProsAccessByOwnerGuid(ProsAccess prosAccess) {
		// TODO Auto-generated method stub
		return prosAccessMapper.selectProsAccessByOwnerGuid(prosAccess);
	}

	@Override
	public List<ProsAccess> selectCheckFileAndAccessByObjectId(String objectId) {
		// TODO Auto-generated method stub
		return prosAccessMapper.selectCheckFileAndAccessByObjectId(objectId);
	}

	@Override
	public List<ProsAccess> selectProsAccessListByOwnerGuid(ProsAccess prosAccess) {
		List<ProsAccess> paList=prosAccessMapper.selectProsAccessListByOwnerGuid(prosAccess);
		if(!StringUtils.isEmpty(paList)) {
			for(ProsAccess pa:paList) {
				   if(pa != null) {
					   String[] subStr=StrUtil.split(pa.getAcceName(), "|");
					   if(subStr.length == 4) {
						   pa.setAcceName(Global.getConfig("ruoyi.bigPlatform")+subStr[1]);
					   }else {
						   pa.setAcceName(null);
					   }
				   }
			   }
		   }
		return paList;
	}

}
